<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order', function (Blueprint $table) {
            $table->increments('id');
            $table->string("order_sn",50)->comment("订单号");
            $table->integer("userid")->comment("用户ID");
            $table->decimal("order_amount",10,2)->default(0)->comment("订单金额");
            $table->decimal("pay_amount",10,2)->default(0)->comment("支付金额");
            $table->integer("goods_num")->default(1)->comment("商品件数");
            $table->string("username",50)->comment("收件人");
            $table->string("phone",30)->comment("联系电话");
            $table->string("address",255)->comment("收货地址");
            $table->string("payment",50)->comment("支付方式(wechat和integal)");
            $table->string("express_company",255)->nullable()->comment("物流公司");
            $table->string("express_code",500)->nullable()->comment("物流单号");
            $table->integer("order_status")->default(0)->comment("-2为删除,-1为已取消,0为待支付,1已支付,2已发货,3已收货,5为已评价,7为退款");
            $table->dateTime("order_time")->comment("下单时间");
            $table->dateTime("pay_time")->nullable()->comment("支付时间");
            $table->dateTime("send_time")->nullable()->comment("发货时间");
            $table->dateTime("finish_time")->nullable()->comment("收货时间");
            $table->dateTime("refund_time")->nullable()->comment("退款时间");
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order');
    }
}
